home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $RCSfile: ffs.h,v $
- ** $Filename: ffs.h $
- ** $Revision: 0.1 $
- ** $Date: $
- **
- ** Defines for FFS on-disk Block structure (version 0.1)
- **
- */
-
- /* Block Types */
-
- #define T_SHORT 0x2 /* header blocks, whatever object */
- #define T_DATA 0x8 /* OFS data blocks */
- #define T_LIST 0x10 /* file extension blocks */
- #define T_DIRLIST 0x21 /* directory cache blocks */
-
- /* Secondary Block Types for filesystem objects */
-
- #define ST_ROOT 1 /* the filesystem root directory */
- #define ST_USERDIR 2 /* user created subdirectories */
- #define ST_SOFTLINK 3 /* soft (symbolic) links */
- #define ST_LINKDIR 4 /* hard link to directory */
- #define ST_FILE -3 /* regular file */
- #define ST_LINKFILE -4 /* hard link to file */
-
- /* Offsets for longword fields in filesystem blocks (negative offsets are relative to the size
- of the block) */
-
- /* Root Directory */
- #define ROOT_TYPE 0
- #define ROOT_HASHSIZE 3
- #define ROOT_CHECKSUM 5
- #define ROOT_HASHTABLE 6
- #define ROOT_BITMAPFLAG -50
- #define ROOT_BITMAPBLOCKS -49
- #define ROOT_BITMAPEXT -24
- #define ROOT_DAYS -23
- #define ROOT_MINS -22
- #define ROOT_TICKS -21
- #define ROOT_DISKNAME -20
- #define ROOT_VOLUMEDAYS -10
- #define ROOT_VOLUMEMINS -9
- #define ROOT_VOLUMETICKS -8
- #define ROOT_CREATIONDAYS -7
- #define ROOT_CREATIONMINS -6
- #define ROOT_CREATIONTICKS -5
- #define ROOT_DIRCACHE -2
- #define ROOT_SECTYPE -1
-
- /* User Directory */
- #define UDIR_TYPE 0
- #define UDIR_OWNKEY 1
- #define UDIR_HASHSIZE 3
- #define UDIR_CHECKSUM 5
- #define UDIR_HASHTABLE 6
- #define UDIR_OWNER -49
- #define UDIR_PROTECTION -48
- #define UDIR_COMMENT -46
- #define UDIR_DAYS -23
- #define UDIR_MINS -22
- #define UDIR_TICKS -21
- #define UDIR_NAME -20
- #define UDIR_LINK -11
- #define UDIR_LINKBACK -10
- #define UDIR_HASHCHAIN -4
- #define UDIR_PARENT -3
- #define UDIR_DIRCACHE -2
- #define UDIR_SECTYPE -1
-
- /* File Header */
- #define FILE_TYPE 0
- #define FILE_OWNKEY 1
- #define FILE_BLOCKCOUNT 2
- #define FILE_FIRSTBLOCK 4
- #define FILE_CHECKSUM 5
- #define FILE_DATABLOCKS 6
- #define FILE_DATABLOCK1 -51
- #define FILE_OWNER -49
- #define FILE_PROTECTION -48
- #define FILE_BYTESIZE -47
- #define FILE_COMMENT -46
- #define FILE_DAYS -23
- #define FILE_MINS -22
- #define FILE_TICKS -21
- #define FILE_NAME -20
- #define FILE_LINKBACK -10
- #define FILE_HASHCHAIN -4
- #define FILE_PARENT -3
- #define FILE_EXTENSION -2
- #define FILE_SECTYPE -1
-
- /* Hard Links */
- #define HLINK_TYPE 0
- #define HLINK_OWNKEY 1
- #define HLINK_CHECKSUM 5
- #define HLINK_OWNER -49
- #define HLINK_PROTECTION -48
- #define HLINK_COMMENT -46
- #define HLINK_DAYS -23
- #define HLINK_MINS -22
- #define HLINK_TICKS -21
- #define HLINK_NAME -20
- #define HLINK_ORIGINAL -11
- #define HLINK_LINKCHAIN -10
- #define HLINK_HASHCHAIN -4
- #define HLINK_PARENT -3
- #define HLINK_SECTYPE -1
-
- /* Soft Links */
- #define SLINK_TYPE 0
- #define SLINK_OWNKEY 1
- #define SLINK_CHECKSUM 5
- #define SLINK_OBJECTNAME 6
- #define SLINK_OWNER -49
- #define SLINK_PROTECTION -48
- #define SLINK_COMMENT -46
- #define SLINK_DAYS -23
- #define SLINK_MINS -22
- #define SLINK_TICKS -21
- #define SLINK_NAME -20
- #define SLINK_HASHCHAIN -4
- #define SLINK_PARENT -3
- #define SLINK_SECTYPE -1
-
- /* File Extension Blocks */
- #define FEXT_TYPE 0
- #define FEXT_OWNKEY 1
- #define FEXT_BLOCKCOUNT 2
- #define FEXT_CHECKSUM 5
- #define FEXT_DATABLOCKS 6
- #define FEXT_DATABLOCK1 -51
- #define FEXT_PARENT -3
- #define FEXT_EXTENSION -2
- #define FEXT_SECTYPE -1
-
- /* OFS Data Blocks */
- #define DATA_TYPE 0
- #define DATA_HEADERKEY 1
- #define DATA_SEQNUM 2
- #define DATA_SIZE 3
- #define DATA_NEXTBLOCK 4
- #define DATA_CHECKSUM 5
- #define DATA_DATABYTES 6
-
- /* DirCache Blocks */
- #define DCACHE_TYPE 0
- #define DCACHE_OWNKEY 1
- #define DCACHE_PARENT 2
- #define DCACHE_NUMENTRIES 3
- #define DCACHE_NEXTBLOCK 4
- #define DCACHE_CHECKSUM 5
- #define DCACHE_DIRENTRIES 6
-
- /* DirCache entries */
- struct ListEntry
- { ULONG Key;
- ULONG Size;
- ULONG Protection;
- ULONG OwnerXID;
- UWORD Days;
- UWORD Min;
- UWORD Tick;
- UBYTE Type;
- UBYTE FileNameLength;
- };
-
- /* BitMap Blocks */
- #define BITMAP_CHECKSUM 0
- #define BITMAP_BITMAPDATA 1
-
- /* BitMap Extension Blocks */
- #define BEXT_POINTERS 0
- #define BEXT_EXTENSION -1
-
- /* Boot Block */
- #define BOOT_ID 0
- #define BOOT_CHECKSUM 1
- #define BOOT_DOSBLOCK 2
- #define BOOT_CODE 3
-
- /* Error codes for FFS support functions */
-
- #define ERR_BADTYPE -129
- #define ERR_BADSECTYPE -130
- #define ERR_BADCHKSUM -131
- #define ERR_BLKCORRUPT -132
- #define ERR_INVBLKNUM -133
-
- /* struct DiskDevice used by FFS support functions */
-
- #define DNAME_SIZE 32
-
- struct DiskDevice
- { UBYTE dd_DeviceName[DNAME_SIZE]; /* Name of exec device */
- ULONG dd_DeviceUnit; /* Device unit number */
- ULONG dd_DeviceFlags; /* OpenDevice flags */
- ULONG dd_SectorSize; /* Physical sector size in bytes */
- ULONG dd_SectorsPerBlock; /* Number of sectors per logical filesystem block */
- ULONG dd_SectorsPerTrack; /* Number of sectors per track */
- ULONG dd_Surfaces; /* Number of surfaces (tracks per cylinder) */
- ULONG dd_LowCyl; /* First cylinder of the partition */
- ULONG dd_HighCyl; /* Last cylinder of the partition */
- ULONG dd_BufMemType; /* Type of memory for data buffers */
- ULONG dd_Flags; /* Special flags */
- ULONG dd_MaxTransfer; /* Maximum Transfer Size */
- ULONG dd_DOSType; /* Filesystem DOSType */
- ULONG dd_Reserved; /* Reserved Blocks (at least 1) */
- ULONG dd_HighKey; /* Highest block number (filled by initFFS) */
- ULONG dd_RootKey; /* Root block number (filled by initFFS) */
- ULONG dd_SectorsPerCyl; /* Number of sectors per cylinder (filled by initFFS) */
- UWORD dd_BlockSizeL; /* Logical block size in longwords (filled by initFFS) */
- UWORD dd_CylStep; /* Number of cylinders to read at once */
- };
-
- #define DDFB_VERBOSE 0 /* Output more information */
- #define DDFB_CUSTOM 1 /* Not scanning a known partition */
- #define DDFB_DO64BIT 2 /* Use 64bit commands */
-
- #define DDFF_VERBOSE (1L << DDFB_VERBOSE)
- #define DDFF_CUSTOM (1L << DDFB_CUSTOM)
- #define DDFF_DO64BIT (1L << DDFB_DO64BIT)
-
- /* Functions in FFSsupport.c */
-
- int initFFS(void);
- ULONG *readblock(ULONG KeyID);
- int writeblock(ULONG *buffer, ULONG KeyID);
- int checkblock(ULONG *buffer, ULONG KeyID, int type, int sectype);
- int checkbmblock(ULONG *buffer);
- ULONG *readbitmap(ULONG *rootblock);
- ULONG findfreeblock(ULONG *bitmap, ULONG StartKey);
- ULONG findcontigfreeblocks(ULONG *bitmap, int numblocks);
- BOOL allocblock(ULONG *bitmap, ULONG KeyID);
- BOOL freeblock(ULONG *bitmap, ULONG KeyID);
- BOOL isfreeblock(ULONG *bitmap, ULONG KeyID);
- ULONG *initheader(ULONG KeyId, ULONG ParentKey, int type, int sectype, STRPTR name);
- void sumblock(ULONG *buffer);
- ULONG hashname(STRPTR name);
- void clearblockptrs(ULONG *header);
- ULONG gethashchain(ULONG *dirblock, ULONG *headerblock);
- int hashlink(ULONG *dirblock, ULONG *headerblock);
-